﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace NimbleTextKeygen
{
    [Obfuscation(Feature = "renaming", ApplyToMembers = true, Exclude = true)]
    public class Settings
    {
        public string ActivationCode
        {
            get;
            set;
        }

        public bool AutoPreview
        {
            get;
            set;
        }

        public bool CheckForUpdates
        {
            get;
            set;
        }

        public DateTime ClientDate
        {
            get;
            set;
        }

        public string ColumnDelimiter
        {
            get;
            set;
        }

        public bool ColumnDelimiterIsRegex
        {
            get;
            set;
        }

        public MRUHistory DataHistory
        {
            get;
            set;
        }

        public SortSettings DataSortSettings
        {
            get;
            set;
        }

        public bool EulaAccepted
        {
            get;
            set;
        }

        public bool? IgnoreEmptyRows
        {
            get;
            set;
        }

        public string InputData
        {
            get;
            set;
        }

        [XmlIgnore]
        public string InputDataFile
        {
            get;
            set;
        }

        public string InputPattern
        {
            get;
            set;
        }

        [XmlIgnore]
        public string InputPatternFile
        {
            get;
            set;
        }

        public string LogFilename
        {
            get;
            set;
        }

        public bool? NormalizeToUnixLineEndings
        {
            get;
            set;
        }

        public int NumRows
        {
            get;
            set;
        }

        public bool? OutputNewLineAfterEachRow
        {
            get;
            set;
        }

        public MRUHistory PatternHistory
        {
            get;
            set;
        }

        public bool? PinAutoPreview
        {
            get;
            set;
        }

        public bool PinColumnDelimiterIsRegex
        {
            get;
            set;
        }

        public bool PinIgnoreEmptyRows
        {
            get;
            set;
        }

        public bool PinOutputNewLineAfterEachRow
        {
            get;
            set;
        }

        public bool PinRowDelimiterIsRegex
        {
            get;
            set;
        }

        public bool PinShowWhereClause
        {
            get;
            set;
        }

        public bool PinTreatConsecutiveFieldDelimitersAsOne
        {
            get;
            set;
        }

        public bool PinTrimEachField
        {
            get;
            set;
        }

        public bool PinUseQualifiers
        {
            get;
            set;
        }

        public bool Pipeline
        {
            get;
            set;
        }

        public string Qualifier
        {
            get;
            set;
        }

        [XmlIgnore]
        public string ResultsFile
        {
            get;
            set;
        }

        public MRUHistory ResultsHistory
        {
            get;
            set;
        }

        public SortSettings ResultSortSettings
        {
            get;
            set;
        }

        public string RowDelimiter
        {
            get;
            set;
        }

        public bool RowDelimiterIsRegex
        {
            get;
            set;
        }

        public bool? RunUnitTest
        {
            get;
            set;
        }

        public MRUHistory SessionHistory
        {
            get;
            set;
        }

        public bool ShowManualActivationLink
        {
            get;
            set;
        }

        public bool ShowWhereClause
        {
            get;
            set;
        }

        public List<Snippet> Snippets
        {
            get;
            set;
        }

        public string Theme
        {
            get;
            set;
        }

        public bool TreatConsecutiveFieldDelimitersAsOne
        {
            get;
            set;
        }

        public bool? TrimFields
        {
            get;
            set;
        }

        public string UniqueCode
        {
            get;
            set;
        }

        public bool UseQualifiers
        {
            get;
            set;
        }

        public string Version
        {
            get;
            set;
        }

        public string WhereClause
        {
            get;
            set;
        }

        [XmlIgnore]
        public string WhereClauseFile
        {
            get;
            set;
        }

        public Rectangle? WindowPosition
        {
            get;
            set;
        }

        public FormWindowState? WindowState
        {
            get;
            set;
        }

        public Settings()
        {
        }

        internal void LoadInput()
        {
            using (StreamReader streamReader = new StreamReader(this.InputDataFile))
            {
                this.InputData = streamReader.ReadToEnd();
            }
        }

        internal void LoadPattern()
        {
            using (StreamReader streamReader = new StreamReader(this.InputPatternFile))
            {
                this.InputPattern = streamReader.ReadToEnd();
            }
        }

        internal void LoadWhereClause()
        {
            using (StreamReader streamReader = new StreamReader(this.WhereClauseFile))
            {
                this.WhereClause = streamReader.ReadToEnd();
            }
        }
    }
}
